package cn.com.dcsgo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 获取请求头信息
 *
 * @author Dcsgo
 * @since 2025/3/2 14:28
 */
@Controller
@RequestMapping("header")
public class HeaderController {

    /**
     * 使用@RequestHeader注解获取请求头信息
     * value name 进行参数绑定
     * required 是否必须
     * defaultValue 默认值
     *
     * @param host host
     * @return String
     */
    @ResponseBody
    @GetMapping("data")
    public String getHeader(@RequestHeader("Host") String host) {
        System.out.println("host = " + host);
        return "host = " + host;
    }
}
